package com.example.shop.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.example.shop.pojo.UserBrowseHistory;
import com.example.shop.pojo.UserGoodsCollection;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserGoodsCollectionMapper extends BaseMapper<UserGoodsCollection> {
    @Select("select * from r_user_goods_collection where user_id=#{userId}")
    List<UserGoodsCollection> selectByUserId(@Param("userId") Long userId);

    @Insert("insert r_user_goods_collection(user_id,goods_id,goods_collection_datetime) " +
            "values(${et.userId},${et.goodsId},#{et.goodsCollectionDateTime}) " +
            "ON DUPLICATE KEY UPDATE goods_collection_datetime = #{et.goodsCollectionDateTime}")
    int insert(@Param(Constants.ENTITY) UserGoodsCollection collection);
}
